package com.msw.axon.dao;

import com.msw.axon.model.User;
import org.springframework.stereotype.Repository;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import java.util.List;

/**
 * × TODO 一句话描述类的含义
 * Created by hadoop on 16-1-14.
 */
@Repository
public class UserDao {

    @PersistenceContext
    private EntityManager entityManager;

    public void save(User user)
    {
        entityManager.persist(user);
    }

    /**
     * 根据文件名称搜索
     *
     * @param fileName
     * @return
     */
    public List<User> queryByName(String fileName)
    {
        TypedQuery<User> query = entityManager.createNamedQuery("queryByName", User.class);
        query.setParameter("name", fileName);
        return query.getResultList();
    }

}
